package com.campus_information_portal.controller;

import com.campus_information_portal.entity.PartyMember;
import com.campus_information_portal.service.PartyActivityService;
import com.campus_information_portal.service.PartyMemberService;
import com.campus_information_portal.service.PartyService;
import com.campus_information_portal.util.Message;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author 20155883 万珊
 * @description 党支部控制层
 * @project_name PartyController
 * @package com.campus_information_portal.controller
 * @create 2018-05-27 9:59
 **/
@Controller
@RequestMapping("/party")
@ResponseBody
@CrossOrigin(origins = "*")
public class PartyController {
    @Autowired
    private PartyService partyService;
    @Autowired
    private PartyMemberService partyMemberService;
    @Autowired
    private PartyActivityService partyActivityService;
    /**
     * @param partyMemberAccount
     * @Description 根据党支部编号party_organization_num查询党支部信息
     * @author 20155883 万珊
     * @methodName queryPartyByPartyOrganizationNum
     * @returnType Message
     * @create 2018/4/26 8:45
     **/
    @RequestMapping(value = "/queryPartyMessage",method = RequestMethod.GET)
    public Message queryPartyMessage(@Param("partyMemberAccount")int partyMemberAccount){
        Message message=new Message();
        int partyOrganizationNum=partyMemberService.findPONBypartyMemberAccount(partyMemberAccount);

        message.add("m1",partyService.queryPartyByPartyOrganizationNum(partyOrganizationNum));
        message.add("m2",partyMemberService.countMember(partyOrganizationNum));
        message.add("m3",partyActivityService.countActivity(partyOrganizationNum));

        return message;
    }
}
